<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改sys_meet_manage')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-manage-edit" th:object="${sysMeetManage}">
            <h4 class="form-header h4">sys_meet_manage信息</h4>
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">紧急程度：</label>
                <div class="col-sm-8">
<!--                    <input name="urgent" th:field="*{urgent}" class="form-control" type="text">
                    <option th:value="*{state}" th:field="*{state}"><span th:text="*{state}"></span></option>-->
                    <select name="urgent" class="form-control">
                        <option th:value="*{urgent}" th:field="*{urgent}"><span th:text="*{urgent}"></span></option>
                        <option value="普通">普通</option>
                        <option value="略紧急">略紧急</option>
                        <option value="紧急">紧急</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">地点：</label>
                <div class="col-sm-8">
<!--                    <input name="local" th:field="*{local}" class="form-control" type="text">-->
                    <select name="local" id="local" class="form-control" >
                        <option th:value="*{local}" th:field="*{local}"><span th:text="*{localName}"></span></option>
                        <option th:each="item,info:${meet}" th:object="${item}" th:value="*{id}">
                            <span th:text="*{name}"></span>
                        </option>
                    </select>
                </div>
            </div>
            <input name="deptId" type="hidden" id="treeId" th:field="*{deptId}"/>
            <div class="form-group">    
                <label class="col-sm-3 control-label">部门：</label>
                <div class="col-sm-8">
<!--                    <input name="deptId" th:field="*{deptId}" class="form-control" type="text">-->
                    <input name="deptId" onclick="selectDeptTree()" id="treeName" type="text" placeholder="默认当前部门" class="form-control">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主持人：</label>
                <div class="col-sm-8">
<!--                    <input name="hostId" th:field="*{hostId}" class="form-control" type="text">-->
                    <select name="hostId" id="hostId" class="form-control" >
                        <option th:value="*{hostId}" th:field="*{hostId}"><span>默认当前主持人</span></option>
                        <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                            <span th:text="*{userName}"></span>
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="beginTime" th:value="${#dates.format(sysMeetManage.beginTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endTime" th:value="${#dates.format(sysMeetManage.endTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">与会人员：</label>
                <div class="col-sm-8">
<!--                    <input name="joinId" th:field="*{joinId}" class="form-control" type="text">-->
                    <select name="joinId" id="joinId" class="form-control" >
                        <option th:value="*{joinId}" th:field="*{joinId}"><span>默认当前与会人员</span></option>
                        <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                            <span th:text="*{userName}"></span>
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分享人员：</label>
                <div class="col-sm-8">
<!--                    <input name="shareId" th:field="*{shareId}" class="form-control" type="text">-->
                    <select name="shareId" id="shareId" class="form-control" >
                        <option th:value="*{shareId}" th:field="*{shareId}"><span>默认当前分享人员</span></option>
                        <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                            <span th:text="*{userName}"></span>
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">内容：</label>
                <div class="col-sm-8">
                    <textarea name="text" class="form-control">[[*{text}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">会议名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">会议类型：</label>
                <div class="col-sm-8">
<!--                    <input name="state" th:field="*{state}" class="form-control" type="text">-->
                    <select name="state" class="form-control" >
                        <option th:value="*{state}" th:field="*{state}"><span th:text="*{state}"></span></option>
                        <option value="0">会议</option>
                        <option value="1">培训</option>
                        <option value="2">其他</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">创建人：</label>
                <div class="col-sm-8">
<!--                    <input name="createId" th:field="*{createId}" class="form-control" type="text">-->
                    <input name="createId" class="form-control" th:value="${user.userId}"  type="hidden">
                    <span th:text="${user.userName}"></span>
                </div>
            </div>
           <!-- <h4 class="form-header h4">sys_meet_room信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/manage";
        $("#form-manage-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-manage-edit').serialize());
            }
        }
        /* 用户管理-新增-选择部门树 */
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/user/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            console.log(deptId)
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
        $("input[name='beginTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            var options = {
                data: [[${sysMeetManage.sysMeetroomList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'name',
                    align: 'center',
                    title: '会议室名称',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].name' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'createName',
                    align: 'center',
                    title: '创建人',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].createName' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'local',
                    align: 'center',
                    title: '地址',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].local' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'people',
                    align: 'center',
                    title: '可容纳人数',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].people' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'area',
                    align: 'center',
                    title: '面积',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].area' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'tou',
                    align: 'center',
                    title: '投影 是否',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].tou' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'text',
                    align: 'center',
                    title: '备注',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].text' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'state',
                    align: 'center',
                    title: '状态 0-可用1-维护',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].state' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    field: 'type',
                    align: 'center',
                    title: '类型 0-普通1-其他',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='sysMeetroomList[%s].type' value='%s'>", index, value);
                        return html;
                    }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                    }
                }]
            };
            $.table.init(options);
        });

        function addRow() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            var row = {
                index: $.table.serialNumber(count),
                name: "",
                createName: "",
                createTime: "",
                local: "",
                people: "",
                area: "",
                tou: "",
                text: "",
                state: "",
                type: "",
            }
            sub.addRow(row);
        }
    </script>
</body>
</html>